<template>
	<z-paging ref="paging" v-model="list" @query="getOrderList" empty-view-text="暂无兑换记录"
		empty-view-img="/static/image/order-empty.png" :empty-view-img-style="{width:'150rpx',height:'150rpx'}"
		:empty-view-title-style="{marginTop: '30rpx'}">
		<template #refresher="{refresherStatus}">
			<!-- 此处的custom-refresh为demo中自定义的组件，非z-paging的内置组件，请在实际项目中自行创建。这里插入什么view，下拉刷新就显示什么view -->
			<custom-refresher :status="refresherStatus" />
		</template>
		<view class="list-box pad-30" v-if="list.length > 0">
			<view @click="hanldeUserId(item)" class="list pad-30 flex centerY bg-white radius30 mar-bottom-30"
				v-for="item in list" :key="item.id">
				<image class="avatar" :src="item.avatar" mode="aspectFill"></image>
				<view class="flex mar-left-20 columnY">
					<view class="address font-30 font-w-500">{{item.name}}</view>
					<view class="font-28 color-646464 mar-top-10">状态：{{item.find_job_status == 1 ? '可接单': '不可接单'}}
					</view>
					<view class="font-28 color-646464 mar-top-10">性别：{{item.gender == 1 ? '男': '女'}}</view>
				</view>
			</view>
		</view>
	</z-paging>
</template>

<script setup>
	import { ref, reactive } from 'vue';
	import { favoriteWorkerPageList } from '@/api/index.js';
	import { onLoad, onShow, onShareAppMessage } from '@dcloudio/uni-app';
	import util from '@/util/share.js'
	import { dataReportFun } from '@/util/dataReport.js'
	import { timeFormat, } from '@/node_modules/uview-plus';

	onLoad((option) => {
		dataReportFun({
			event: "client.page_view",
		})
	});

	const list = ref([]);
	const paging = ref(null);
	const getOrderList = (page, pageSize) => {
		favoriteWorkerPageList({
			page,
			ps: pageSize
		}).then(res => {
			if (res?.code == 200) {
				paging.value.complete(res.data.data);
			} else {
				paging.value.complete(false);
			}
		})
	}

	// 分享
	onShareAppMessage(() => {
		return util.onShare({
			path: `/pages/my_actions/collectionLog/collectionLog`
		})
	})

	const hanldeUserId = (item) => {
		uni.navigateTo({
			url: '/pages/worker/detail?worker_id=' + item.id
		})
	}
</script>

<style scoped lang="scss">
	.list-box {
		background: #F4F6F8;
	}

	.avatar {
		width: 140rpx;
		height: 140rpx;
		border-radius: 50%;
	}
</style>